package iqq.ui.view;

import iqq.Logger;

import java.util.HashMap;
import java.util.Map;

import javax.swing.JRootPane;

/**
 * @author ChenZhiHui
 * @create-time 2013-3-10
 */
public class ViewManager {
	private static Map<Class<? extends JRootPane>, JRootPane> rootPanes = new HashMap<Class<? extends JRootPane>, JRootPane>();

	public static JRootPane get(Class<? extends JRootPane> clazz) {
		JRootPane rootPane = rootPanes.get(clazz);
		if (rootPane == null) {
			try {
				rootPane = clazz.newInstance();
				rootPanes.put(clazz, rootPane);
			} catch (InstantiationException e) {
				Logger.fatal(e.getMessage());
			} catch (IllegalAccessException e) {
				Logger.fatal(e.getMessage());
			}
		}
		return rootPane;
	}

	public static void remove(Class<? extends JRootPane> clazz) {
		rootPanes.remove(rootPanes);
	}
}
